<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page import="com.onlineMIS.ORM.entity.headQ.barcodeGentor.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改条型码资料</title>
<%@ include file="../../common/Style.jsp"%>
<script>
	$(document).ready(function() {
		parent.$.messager.progress('close');
		$("#org_table tr").mouseover(function() {
			$(this).addClass("over");
		}).mouseout(function() {
			$(this).removeClass("over");
		});
		$("#clearBt").removeAttr("disabled");
	});

	function del() {
		var info = "你确定删除此商品条码信息?<br\>此商品信息一经删除所有相关单据都将删除对应信息!";
		$.messager.confirm('确认', info, function(r) {
			if (r) {
				var params = $("#updateProductForm").serialize();
				$.post("action/productJSONAction!checkBarcode", params,
						backProcess, "json");
			}
		});

	}
	function backProcess(data) {
		var result = data.result;
		if (result == false) {
			document.updateProductForm.action = "action/productJSPAction!delete";
			document.updateProductForm.submit();
		} else {
			$.messager.alert('操作失败', "此条码已经使用无法删除！", 'error');
		}
	}
	function update() {

		var sizeMin = [ 30, 40, 50, 60, 70, 80, 90 ];
		var sizeMax = [ 110, 120, 130, 140, 150, 160, 170 ];

		if ($('#updateProductForm').form('validate')) {
			var error = "";

			var brandId = $("#brand_ID").val();
			if (brandId == "" || brandId == 0) {
				error += "品牌 - 是必选项<br/>";
			} else if (!isValidPositiveInteger(brandId)) {
				error += "品牌 - 必须是系统已经存在的信息，请检查<br/>";
			}

			var categoryLevelId = $("#category_level_ID").combo("getValue");
			if (categoryLevelId != "0"
					&& !isValidPositiveInteger(categoryLevelId)) {
				alert("产品线类型不是一个正确的输入");
				return;
			}

			var sizeMin = $("#sizeMin").val();
			if (sizeMin.includes(sizeMin) && !isValidPositiveInteger(sizeMin)) {
				alert("最小码不是一个正确的输入");
				return;
			}

			var sizeMax = $("#sizeMax").val();
			if (sizeMax.includes(sizeMax) && !isValidPositiveInteger(sizeMax)) {
				alert("最大码不是一个正确的输入");
				return;
			}

			var costMultiple = $("#costMultiple").val();
			if (costMultiple != "" && isNaN(costMultiple)) {
				error += "成本倍数 - 必须是数字\n";
				$("#costMultiple").focus();
			} else if (costMultiple != "" && costMultiple == 0) {
				$("#costMultiple").val("");
			}

			var categoryId = $("#category").combobox("getValue");
			if (categoryId == "") {
				error += "货品类 - 是必选项<br/>";
			} else if (!isValidPositiveInteger(categoryId)) {
				error += "货品类 - 必须是系统已经存在的类别，请检查<br/>";
			}

			if (error == "") {
				if (error != "")
					$.messager.alert('操作失败', error, 'error');
				else {
					document.updateProductForm.action = "action/productJSPAction!update";
					document.updateProductForm.submit();
				}
			} else {
				$.messager.alert('操作失败', error, 'error');

			}
		}

	}
</script>
</head>
<body>
	<table width="90%" align="center" class="OuterTable">
		<tr>
			<td><s:form id="updateProductForm" name="updateProductForm"
					method="post" action="" theme="simple">
					<table width="100%" border="0" id="org_table">
						<tr class="PBAOuterTableTitale">
							<th colspan="2">修改条形码信息</th>
						</tr>
						<tr>
							<td colspan="2"><div class="errorAndmes">
									<s:actionerror cssStyle="color:red" />
									<s:actionmessage cssStyle="color:blue" />
								</div></td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>归属</strong> :</td>
							<td><s:if test="uiBean.product.chainStore != null">
									<s:property value="uiBean.product.chainStore.chain_name" />
								</s:if> <s:else>
	                总部
	              </s:else></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18"><strong>商品编码</strong> :</td>
							<td><s:property value="uiBean.product.product.serialNum" /></td>

						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>条形码 </strong> :</td>
							<td><s:property value="uiBean.product.barcode" /> <input
								type="hidden" name="formBean.productBarcode.barcode"
								value="<s:property value="uiBean.product.barcode"/>" /> <input
								type="hidden" name="formBean.productBarcode.id"
								value="<s:property value="uiBean.product.id"/>" /> <input
								type="hidden" name="formBean.productBarcode.product.productId"
								value="<s:property value="uiBean.product.product.productId"/>" />
							</td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18"><strong>品牌 </strong> :</td>
							<td><%@ include file="SearchBrandStub.jsp"%></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18" style="background-color: rgb(255, 250, 208);"><strong>年份 </strong> :</td>
							<td><s:select
									name="formBean.productBarcode.product.year.year_ID" size="1"
									id="year" list="uiBean.basicData.yearList" listKey="year_ID"
									listValue="year" /></td>
						</tr>
						<tr class="InnerTableContent"
							>
							<td height="18"><strong>季度</strong> :</td>
							<td><s:select
									name="formBean.productBarcode.product.quarter.quarter_ID"
									size="1" id="quarter" list="uiBean.basicData.quarterList"
									listKey="quarter_ID" listValue="quarter_Name" /></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18" style="background-color: rgb(255, 250, 208);"><strong>产品线</strong> :</td>
							<td><s:select
									name="formBean.productBarcode.product.categoryLevel1.category_ID"
									style="width:130px" cssClass="easyui-combobox" size="1"
									id="category_level_ID"
									list="uiBean.basicData.categoryLevelList" listKey="category_ID"
									listValue="category_Name" /></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18"><strong>类别</strong> :</td>
							<td><s:select
									name="formBean.productBarcode.product.category.category_ID"
									cssClass="easyui-combobox" size="1" id="category"
									list="uiBean.basicData.categoryList" listKey="category_ID"
									listValue="category_Name" /></td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>产品货号</strong>:</td>
							<td><s:textfield
									name="formBean.productBarcode.product.productCode"
									id="productCode" />*</td>
						</tr>

						<tr class="InnerTableContent">
							<td height="18"><strong>齐码数量 </strong> :</td>
							<td><s:select
									name="formBean.productBarcode.product.numPerHand" size="1"
									id="numPerHand" list="uiBean.basicData.numPerHandList"
									listKey="numPerHand" listValue="numPerHand" /></td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>单位 </strong> :</td>
							<td><s:select name="formBean.productBarcode.product.unit"
									size="1" id="unit" list="uiBean.basicData.unitList"
									listKey="productUnit" listValue="productUnit" /></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18"><strong>颜色</strong> :</td>
							<td><s:property value="uiBean.product.color.name" /></td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>最小码</strong> :</td>
							<td><s:select id="sizeMin" name="formBean.productBarcode.product.sizeMin"  list="#{'60':'60','70':'70','80':'80','90':'90','100':'100','110':'110','120':'120','130':'130','140':'140','150':'150','160':'160','170':'170'}" listKey="key" listValue="value" headerKey="0" headerValue="--" />
							</td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>最大码</strong> :</td>
							<td><s:select id="sizeMax" name="formBean.productBarcode.product.sizeMax"  list="#{'110':'110','120':'120','130':'130','140':'140','150':'150','160':'160','170':'170','180':'180','190':'190'}" listKey="key" listValue="value" headerKey="0" headerValue="--" />
							</td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>面料</strong> :</td>
							<td><s:textfield cssClass="easyui-textbox"
									name="formBean.productBarcode.product.material" id="material" /></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18"><strong>千禧零售价 </strong> :</td>
							<td><input type="text"
								name="formBean.productBarcode.product.salesPrice"
								id="salesPrice"
								value="<s:if test="uiBean.product.product.salesPrice!=0"><s:property value="uiBean.product.product.salesPrice"/></s:if>"
								size="10" /></td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>进价 </strong> :</td>
							<td><input type="text"
								name="formBean.productBarcode.product.recCost" id="recCost"
								value="<s:if test="uiBean.product.product.recCost!=0"><s:property value="uiBean.product.product.recCost"/></s:if>"
								size="10" /></td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>成本倍数 </strong> :</td>
							<td><input type="text"
								name="formBean.productBarcode.product.costMultiple"
								id="costMultiple"
								value="<s:if test="uiBean.product.product.costMultiple!=0"><s:property value="uiBean.product.product.costMultiple"/></s:if>"
								size="10" /></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18"><strong>预设价1 </strong> :</td>
							<td><input type="text"
								name="formBean.productBarcode.product.wholeSalePrice"
								id="wholeSalePrice"
								value="<s:if test="uiBean.product.product.wholeSalePrice!=0"><s:property value="uiBean.product.product.wholeSalePrice"/></s:if>"
								size="10" /></td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>预设价2 </strong> :</td>
							<td><input type="text"
								name="formBean.productBarcode.product.wholeSalePrice2"
								id="wholeSalePrice2"
								value="<s:if test="uiBean.product.product.wholeSalePrice2!=0"><s:property value="uiBean.product.product.wholeSalePrice2"/></s:if>"
								size="10" /></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18"><strong>预设价3 </strong> :</td>
							<td><input type="text"
								name="formBean.productBarcode.product.wholeSalePrice3"
								id="wholeSalePrice3"
								value="<s:if test="uiBean.product.product.wholeSalePrice3!=0"><s:property value="uiBean.product.product.wholeSalePrice3"/></s:if>"
								size="10" /></td>
						</tr>
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td height="18"><strong>厂家零售价 </strong> :</td>
							<td><input type="text"
								name="formBean.productBarcode.product.salesPriceFactory"
								id="salesPriceFactory"
								value="<s:if test="uiBean.product.product.salesPriceFactory!=0"><s:property value="uiBean.product.product.salesPriceFactory"/></s:if>"
								size="10" /></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18"><strong>折扣 </strong> :</td>
							<td><input type="text"
								name="formBean.productBarcode.product.discount" id="discount"
								value="<s:if test="uiBean.product.product.discount!=0"><s:property value="uiBean.product.product.discount"/></s:if>"
								size="10" /></td>
						</tr>
<!-- 					<tr class="InnerTableContent" style="background-color: rgb(255, 250, 208);">
							<td height="18">图片:</td>
							<td><input class="easyui-filebox" id="picture" 
								name="formBean.inventory"  buttonText="上传" buttonIcon="icon-ok" style="width: 180px"
								data-options="prompt:'请上传图片',onChange:change_photo,accept:'image/jpeg,image/png'">
								<a href="#" id="clearBt" class="easyui-linkbutton"  onclick="clearImage();"  data-options="iconCls:'icon-no',toggle:true">清除</a>
								</td>
						</tr>
						<tr class="InnerTableContent" style="background-color: rgb(255, 250, 208);">
							<td height="18">本次修改图片:</td>
							<td rowspan="2" id="imgtd"><img id="img" src="<%=request.getContextPath()%>/conf_files/web-image/default.png"
								style="height: 90px; width: 130px" />
						</tr>
						<tr class="InnerTableContent" style="background-color: rgb(255, 250, 208);">
							<td height="18"></td>
							<td></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="18">已上传图片:</td>
							<td rowspan="2" ><img id="uploaded" src="'imgPath'+<s:property value="uiBean.product.product.discount"/>"
								style="height: 90px; width: 130px" />
						</tr>
						<tr class="InnerTableContent">
							<td height="18"></td>
							<td></td>
						</tr> -->	
						<tr class="InnerTableContent"
							style="background-color: rgb(255, 250, 208);">
							<td colspan="2"><input type="button" value="更新"
								onclick="update();" />&nbsp;&nbsp;<input type="button"
								value="删除" onclick="del();" />&nbsp;&nbsp;<input type="button"
								value="取消" onclick="window.close();" /></td>
						</tr>
					</table>
				</s:form></td>
		</tr>
	</table>
</body>
</html>